package io.renren.membermanage.task;

import io.renren.membermanage.service.GenerateLogService;
import jakarta.annotation.PostConstruct;
import jakarta.annotation.Resource;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

@Component
public class ClearLogTasks {

    @Resource
    private GenerateLogService logService;

    @PostConstruct
    public void init() {
        // 后续可记录相关日志信息
    }

    @Scheduled(cron = "0 0 0 * * ?") // 每天 0 点执行
    public void cleanLogs() {
        System.out.println("Cleaning logs at: " + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
        logService.cleanLogs();
    }

}
